#!ipxe

# Debian Operating System
# http://www.debian.org

goto ${menu}

:debian
set os Debian
set os_arch ${arch}
iseq ${os_arch} x86_64 && set os_arch amd64 ||
iseq ${os_arch} i386 && set os_arch i386 ||
iseq ${os_arch} arm64 && set os_arch arm64 ||
clear debian_version
clear older_release
menu ${os} - ${os_arch}
item --gap Latest Releases
{% for item in releases.debian.versions.stable %}
item {{ item.code_name }} ${space} ${os} {{ item.name }}
{% endfor %}
item --gap Testing Releases
{% for item in releases.debian.versions.testing %}
item {{ item.code_name }} ${space} ${os} {{ item.name }}
{% endfor %}
item --gap Older Releases
item older_release ${space} Set release codename...
choose debian_version || goto debian_exit
iseq ${debian_version} older_release && goto older_release ||
goto mirrorcfg

:older_release
set older_release true
set debian_mirror {{ releases.debian.archive_mirror }}
echo Setting mirror to ${debian_mirror}
clear debian_version
echo -n Please set enter code name of release: ${} && read debian_version
set dir ${debian_base_dir}/dists/${debian_version}/main/installer-${os_arch}/current/images/netboot/
goto deb_boot_type

:mirrorcfg
set debian_mirror ${debian_mirror}
set mirrorcfg mirror/suite=${debian_version}
set dir ${debian_base_dir}/dists/${debian_version}/main/installer-${os_arch}/current/images/netboot/
goto deb_boot_type

:deb_boot_type
menu ${os} [${debian_version}] Installer
item --gap Install types
item text ${space} Text Based Install
item graphical ${space} Graphical Based Install
item rescue ${space} Rescue Mode
item expert ${space} Expert Install
item preseed ${space} Specify preseed url...
choose --default ${type} type || goto debian

echo ${cls}
goto deb_${type}

:deb_rescue
set install_params rescue/enable=true
goto deb_text

:deb_expert
set install_params priority=low
goto deb_text

:deb_preseed
echo -n Specify preseed URL for ${os} ${debian_version}: && read preseedurl
set install_params auto=true priority=critical preseed/url=${preseedurl}
goto deb_text

:deb_text
set dir ${dir}${menu}-installer/${os_arch}
goto deb_boot

:deb_graphical
set dir ${dir}gtk/${menu}-installer/${os_arch}
set install_params vga=788
goto deb_boot

:deb_boot
imgfree
kernel ${debian_mirror}/${dir}/linux ${install_params} ${netcfg} ${mirrorcfg} {{ kernel_params }}
initrd ${debian_mirror}/${dir}/initrd.gz
echo
echo MD5sums:
md5sum linux initrd.gz
boot

:debian_exit
clear menu
exit 0
